package com.yungu.swift.admin.route.system;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.base.model.admin.AdminParam;
import com.yungu.swift.common.model.param.AdminSensitiveWordParam;
import com.yungu.swift.common.service.CommonSensitiveWordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : cuixiuyin
 * @date : 2019/6/15
 */
@RestController
@RequestMapping("/admin/v1/system/sensitiveWord")
@Api(value = "【系统服务】", tags = "敏感词设置中心")
public class SensitiveWordAdmin {

    @Reference
    private CommonSensitiveWordService commonSensitiveWordService;

    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @ApiOperation(value = "敏感词信息查询", httpMethod = "GET")
    public ResponseData<String> info(@RequestBody AdminParam adminParam) {
        return commonSensitiveWordService.getInitSensitiveWords();
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ApiOperation(value = "敏感词信息更新", httpMethod = "POST")
    public ResponseData<Boolean> update(@RequestBody AdminSensitiveWordParam sensitiveWordParam) {
        return commonSensitiveWordService.update(sensitiveWordParam.getSensitiveWords());
    }
}
